package com.chenxin.wms.controller;

import com.chenxin.common.annotation.Log;
import com.chenxin.common.core.controller.BaseController;
import com.chenxin.common.core.domain.AjaxResult;
import com.chenxin.common.core.page.TableDataInfo;
import com.chenxin.common.enums.BusinessType;
import com.chenxin.common.utils.poi.ExcelUtil;
import com.chenxin.wms.domain.StationEntity;
import com.chenxin.wms.domain.vo.StationVO;
import com.chenxin.wms.service.IStationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 站台资料Controller
 *
 * @author gry
 * @date 2025-04-08
 */
@RestController
@RequestMapping("/wms/station")
public class StationController extends BaseController {
    @Autowired
    private IStationService stationService;

    /**
     * 查询站台资料列表
     */
    @PreAuthorize("@ss.hasPermi('wms:station:list')")
    @GetMapping("/list")
    public TableDataInfo list(StationVO stationVo) {
        startPage();
        List<StationVO> list = stationService.selectStationList(stationVo);
        return getDataTable(list);
    }

    /**
     * 导出站台资料列表
     */
    @PreAuthorize("@ss.hasPermi('wms:station:export')")
    @Log(title = "站台资料", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StationVO stationVo) {
        List<StationVO> list = stationService.selectStationList(stationVo);
        ExcelUtil<StationVO> util = new ExcelUtil<>(StationVO.class);
        util.exportExcel(response, list, "站台资料数据");
    }

    /**
     * 修改站台资料
     */
    @PreAuthorize("@ss.hasPermi('wms:station:edit')")
    @Log(title = "站台资料", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StationEntity stationEntity) {
        return toAjax(stationService.updateStation(stationEntity));
    }

    /**
     * 禁用站台资料
     */
    @PreAuthorize("@ss.hasPermi('wms:station:remove')")
    @Log(title = "站台资料", businessType = BusinessType.DELETE)
    @DeleteMapping("/{stationIds}")
    public AjaxResult remove(@PathVariable Long[] stationIds) {
        return success("站台禁用成功");
    }
}
